<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>即时订单 - 胎大王</title>
	{include file='common/head' /}
	<link href="css/jquery.jqzoom.css" rel="stylesheet" type="text/css" />
	<script src="js/layer/layer.js"></script>
</head>
<body>
<div class="container">
{include file='common/top' /}
	<div class="deposit">
		<div class="deposit-banner"></div>
		<div class="contai">
			<div class="f-bk30"></div>
			<div class="deposit-tit">
				<strong>即时订单</strong>
			</div>
			<p>即时订单说明：即时订单不限规格，单个即时订单最低购买数量为20条，抢购时需要支付全额货款。</p>
			<div class="f-bk30"></div>
			<div class="deposit-content">
				<div class="deposit-title">
					<strong>TDW产品列表</strong>
					<div class="more">TDW PRODUCT LIST</div>
				</div>
				<div class="f-bk3"></div>
				<div class="tdw-qiehuan">
					<a href="javascript:;" class="act">精品轮胎</a>
					<a href="javascript:;">轮胎配件</a>
				</div>
				<div class="f-bk3"></div>
				<div class="con-list">
				{volist id="vo" name="data['productArray']"}
				<div class="deposit-list">
					<div class="pure-g">
						<div class="pure-u-6-24">
							<a href="/depositDetail.html?id={$vo.id}&poolQuantity={$vo.poolInfo.quantity}"><img src="{$vo.img}" alt="{$vo.name}"></a>
						</div>
						<div class="pure-u-18-24" style="position: relative;">
							<div class="info">
								<a href="/depositDetail.html?id={$vo.id}&poolQuantity={$vo.poolInfo.quantity}"><p>{$vo.name}</p></a>
							</div>
							<div class="price">
								￥{$vo.price}
							</div>
							<div class="type-list">
								<ul>
									<li>·规格：{$vo.spec}</li>
									<li>·花纹：{$vo.huawen}</li>
									<li>·轮位：{$vo.position}</li>
								</ul>
							</div>
							<div class="type">
								<div><span class="span_tit">库存：</span><span>{$vo.poolInfo.quantity}条</span></div>
							</div>
							<div class="deposit-botton">
								<ul>
									<li><div class="num">· 抢购数量 <span class="reduc">&nbsp;-&nbsp;</span><input name="numinput" class="numinput" type="text" id="text_box" value="1" /><span class="add">+</div></li>

									<li>
									<input type="hidden" value="{$vo.id}" name='productId' />
									<input type="hidden" value="{$vo.poolInfo.quantity}" name='poolQuantity' />
									<div class="umall">
									<a href="javascript:;" class="addCart">加入购物车</a> 
									<a href="javascript:;" class="buy">立即抢购</a>
									</div>
									</li>
								</ul>
							</div>
						</div>
					</div>
				</div>
				{/volist}
				</div>
				<div class="con-list hide">
				{empty name="data['partsArray']"}
				  <div style="text-align:center;padding: 5rem 0;">
					<img src="__IMG__/success.png">
					<p style="color: #ec6c00;">暂无配件</p>
				  </div>
				{else /}
				{volist id="vo" name="data['partsArray']"}
				<div class="deposit-list">
					<div class="pure-g">
						<div class="pure-u-6-24">
							<a href="/depositDetail.html?id={$vo.id}&poolQuantity={$vo.poolInfo.quantity}"><img src="{$vo.img}" alt="{$vo.name}"></a>
						</div>
						<div class="pure-u-18-24" style="position: relative;">
							<div class="info">
								<a href="/depositDetail.html?id={$vo.id}&poolQuantity={$vo.poolInfo.quantity}"><p>{$vo.name}</p></a>
							</div>
							<div class="price">
								￥{$vo.price}
							</div>
							<div class="type-list">
								<ul>
									<li>  </li>
								</ul>
							</div>
							<div class="type">
								<div><span class="span_tit">库存：</span><span>{$vo.poolInfo.quantity}</span></div>
							</div>
							<div class="deposit-botton">
								<ul>
									<li><div class="num">· 抢购数量 <span class="reduc">&nbsp;-&nbsp;</span><input name="numinput" class="numinput" type="text" id="text_box" value="1" /><span class="add">+</div></li>

									<li>
									<input type="hidden" value="{$vo.id}" name='productId' />
									<input type="hidden" value="{$vo.poolInfo.quantity}" name='poolQuantity' />
									<div class="umall">
									<a href="javascript:;" class="addCart">加入购物车</a> 
									<a href="javascript:;" class="buy">立即抢购</a>
									</div>
									</li>
								</ul>
							</div>
						</div>
					</div>
				</div>
				{/volist}
				{/empty}
				</div>

				
		</div>
	</div>
	{include file='common/foot' /}
</div>
{include file='common/back' /}
<script>
$(function(){
	$(".reduc").each(function() {
		$(this).click(function() {
			var $multi1 = 0;
			var vall1 = $(this).next().val();
			vall1--;
			if(vall1 <= 0) {
				vall1 = 1;
			}
			$(this).next().val(vall1);

		})
	});
	$(".add").each(function() {
		$(this).click(function() {
			var $multi = 0;
			var vall = parseInt($(this).prev().val());
			vall++;
			$(this).prev().val(vall);
		})

	});
	$(".addCart").click(function(){
		var quantity = $(this).closest("ul").find("input[name='numinput']").val();
		var productId = $(this).parents("li").find("input[name='productId']").val();
		var poolQuantity = $(this).parents("li").find("input[name='poolQuantity']").val();
		if (/^\d*[1-9]\d*$/.test(quantity) && parseInt(quantity) > 0) {
			if(parseInt(poolQuantity)<parseInt(quantity)){
				layer.msg("库存不足无法加入购物车",{time:1500});
				return false;
			}
			$.ajax({
				url: "/Cart/addCart.html",
				type: "POST",
				data: {id:productId,quantity:quantity},
				dataType: "json",
				cache: false,
				success: function(data) {
					if(data.code==1){
						layer.msg("添加成功",{time:1500});
					}else if(data.code==1004){
						layer.alert(data.msg,function(){
							window.location.href='/login/jump/deposit.html';					
						});						
					}else{
						layer.msg(data.msg,{time:1500});
					}
				}
			});
		} else {
			layer.msg("加入购物车失败",{time:1500});
		}
	});
	$(".buy").click(function(){
		var quantity = $(this).closest("ul").find("input[name='numinput']").val();
		var productId = $(this).parents("li").find("input[name='productId']").val();
		var poolQuantity = $(this).parents("li").find("input[name='poolQuantity']").val();
		if (/^\d*[1-9]\d*$/.test(quantity) && parseInt(quantity) > 0) {
			if(parseInt(poolQuantity)<parseInt(quantity)){
				layer.msg("库存不足无法购买",{time:1500});
				return false;
			}
			$.ajax({
				url: "/Cart/addCart.html",
				type: "POST",
				data: {id:productId,quantity:quantity},
				dataType: "json",
				cache: false,
				success: function(data) {
					if(data.code==1){
						//layer.alert("添加成功",function(){
							window.location.href='/cart.html';					
						//});	
					}else if(data.code==1004){
						layer.alert(data.msg,function(){
							window.location.href='/login/jump/deposit.html';					
						});						
					}else{
						layer.msg(data.msg,{time:1500});
					}
				}
			});
		} else {
			layer.msg("购买失败",{time:1500});
		}
	});	
	//切换
  tabs($(".tdw-qiehuan a"), $('.con-list'));
});
var tabs = function(tab, con){
	    tab.click(function(){
	        var indx = tab.index(this);
	        tab.removeClass('act');
	        $(this).addClass('act');
	        con.hide();
	        con.eq(indx).show();
	    })    
	}
</script>
</body>
</html>